package com.example.administrator.exkotlin.broadcast

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.widget.Toast

class MyTestReceiver02 : BroadcastReceiver() {
    companion object {
        const val MY_BROACAST_TEST_01 = "com.lp.exkotlin.testBroacast01"
    }

    override fun onReceive(context: Context, intent: Intent) {
        when (intent.action) {
            MY_BROACAST_TEST_01 -> {
                val longExtra = intent.getLongExtra("test01", 0L)
                Toast.makeText(context, "收到自定义广播02$longExtra", Toast.LENGTH_SHORT).show()
                //使用abortBroadcast拦截广播，让优先级之后的无法收听
                abortBroadcast()
            }
        }
    }
}
